#include "manager.h"

manager::manager(){

}
manager::~manager(){

}

int manager::createConn(){

	frontConn = new front();
	if( frontConn == NULL ){
		return -1;
	}
	frontConn->setManager(this);
	
	backConn = new back();
	if( backConn == NULL ){
		return -1;
	}
	backConn->setManager(this);
	return 0;
	
}

int manager::setFrontFd(int fd){
	if( frontConn == NULL ){
		return -1;
	}
	frontConn->setFd(fd);
	return 0;
}

int manager::sendToBack(const char*msg, int msg_len){
	printf("sendToBack\n");
	backConn->send(msg, msg_len);
	return 0;
}

int manager::sendToFront(const char*msg, int msg_len){
	printf("sendToFront\n");
	frontConn->send(msg, msg_len);
	return 0;

}


int manager::closeConn(){

	frontConn->close();
	backConn->close();
	delete frontConn;
	delete backConn;
	return 0;

}


